package com.hellloop.pim.alphabeat.entity;

import java.util.Hashtable;

public class GameRoom {
	Hashtable<Integer, GamePlayer> players = null;
	Hashtable<Integer, Player> watchers = null;
	Sentence [] sentences = null;
	
	private int slen;
	private int typingIndex;
	private int sentenceCount;
	
	public GameRoom( Hashtable<Integer, Player> players, Hashtable<Integer, Player> watchers, Sentence [] sentences) {
		this.players = new Hashtable<Integer, GamePlayer>();
		this.watchers = new Hashtable<Integer, Player>();

		for( Player p : players.values())
			this.players.put( new Integer(p.playerId), new GamePlayer(p, p.playerId));

		int i = 0;
		for( Player o : watchers.values())
			this.watchers.put( new Integer(i++), o);

		this.sentences = sentences;
		setSentenceCount();
	}

	public int getSlen() { return slen;}
	public int getTypingIndex() { return typingIndex;}
	public Sentence [] getSentences() { return sentences;}
	public Sentence getSentence( int index) { return sentences[index];}
	public Sentence currentSentence() { return sentences[typingIndex];}
	public String getMessage( int index) { return getSentence(index).msg;}
	public String currentMessage() { return currentSentence().msg;}
	public int getSentenceCount() { return sentenceCount;}

	public void setSlen(int slen) { this.slen = slen;}
	public void setTypingIndex(int typingIndex) { this.typingIndex = typingIndex;}
	public void nextType() { this.typingIndex++;}
	public void setSentenceCount() { this.sentenceCount = sentences.length;}
}
